To set a value to an environment variable, use the following syntax:

```baml
env.YOUR_VARIABLE_NAME
```

<Warning>Environment variables with spaces in their names are not supported.</Warning>

### Example

Using an environment variable for API key:

```baml
client<llm> MyCustomClient {
    provider "openai"
    options {
        model "gpt-5-mini"
        // Set the API key using an environment variable
        api_key env.MY_SUPER_SECRET_API_KEY
    }
}
```

<Markdown src="/snippets/setting-env-vars.mdx" />

## Error Handling
Errors for unset environment variables are only thrown when the variable is accessed. If your BAML project has 15 environment variables and 1 is used for the function you are calling, only that one environment variable will be checked for existence.
